/*
 * (C) APUE
 * Use exit handler that will be called when exit.
 * Register the handler using atexit
 * Be careful the orders(FILO, like stack) and times.
 */
#include "apue.h"

static void my_handler1();
static void my_handler2();

int main()
{
	if (atexit(my_handler2) != 0)
		err_quit("register exit handler failed.");
	if (atexit(my_handler1) != 0)
		err_quit("register exit handler failed.");
	if (atexit(my_handler1) != 0)
		err_quit("register exit handler failed.");

	printf("main is done.\n");
	return 0;
}

static void my_handler1()
{
	printf("first exit handler\n");
}

static void my_handler2()
{
	printf("second exit handler\n");
}
